package export.monster
{
	import base.BaseMonster;
	
	import com.dusk.util.RandomUtil;
	import com.game.engine.MainGame;
	import com.game.manager.AnimationManager;
	import export.aura.AuraRed;
	import export.bullet.FollowTargetBullet;
	import export.bullet.RegionBullet;
	
	import flash.geom.ColorTransform;
	import flash.geom.Rectangle;
	
	public class Monster403 extends BaseMonster
	{
		
		//二阶牛魔王
		
		public function Monster403()
		{
			super();
		}
		
		override protected function initBBDC() : void
		{
			bbdc = AnimationManager.getAnimation("Monster403Action");
			bbdc.setAction("idle");
			bbdc.turnRight();
			bbdc.addCallBack(onEnterFrame, onActionOver);
			bodyContainer.addChild(bbdc);
		}
		
		override protected function initCollideArea() : void
		{
			collideBox = new Rectangle(-30,-90,60,90);
			super.initCollideArea();
		}
		
		override protected function onEnterFrame(action:String, frameCount:int):void
		{
			switch (action)
			{
				case "attack1":
					if(frameCount == 1)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setHurt(getActionHurt("attack1"));
						b.setCollideArea(0,-150,140 * bbdc.getDirect(),150);
						b.setDirect(bbdc.getDirect());
						b.setAction("Monster403Attack1");
						b.setDestroyInCount(bbdc.frameLeft);
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
					break;
				case "skill1":
					if(frameCount == 2)
					{
						var bu:FollowTargetBullet = new FollowTargetBullet("Monster403Bullet2");
						bu.setOwner(this);
						bu.setDisable();
						bu.setDirect(bbdc.getDirect());
						bu.setClipOffset(0,-50);
						bu.setIsDestroyWhenLastFrame(true);
						bu.transform.colorTransform = new ColorTransform(1,0.5,0.5);
						gc.gameScene.addChild(bu);
						magicBulletArray.push(bu);
					}
			}
		}
		
		override protected function onActionOver(action:String):void
		{
			switch(action)
			{
				case "skill1":
					for(var i:int = RandomUtil.randInt(3,5);i > 0; i--)
					{
						var aura:AuraRed = new AuraRed(this.curAttackTarget,this);
						aura.x = RandomUtil.randInt(this.curAttackTarget.x - 10, this.curAttackTarget.x + 10);
						aura.y = RandomUtil.randInt(this.curAttackTarget.y - 10, this.curAttackTarget.y + 10);
						aura.setPower(1000);
						gc.gameScene.addChild(aura);
						gc.pWorld.getAuraArray().push(aura);
					}
					break;
				case "dead":
					MainGame.getIns().createMonster(404,470,370);
			}
			super.onActionOver(action);
		}
		
		override protected function beforeSkill1Start() : Boolean
		{
			return hasTarget();
		}
		
		override public function destroy() : void
		{
			super.destroy();
		}
		
		/*override protected function beforeSkill2Start() : Boolean
		{
			return this.curAttackTarget && AUtils.GetDisBetweenTwoObj(this.curAttackTarget,this) <= 80;
		}
		
		override protected function releSkill1() : void
		{
			this.faceToTarget();
			
			this.setInvincible(48);
			this.setAction("hit2_1");
			this.lastHit = "hit2_1";
		}
		
		override protected function releSkill2() : void
		{
			this.faceToTarget();
			
			this.setInvincible(40);
			this.setAction("hit3");
			this.lastHit = "hit3";
		}
		
		private function doHi1(direct:uint) : void
		{
			var b:SpecialEffectBullet = new SpecialEffectBullet("Monster403Bullet1");
			if(direct == 0)
			{
				b.x = this.x - 120;
			}
			else
			{
				b.x = this.x + 120;
			}
			b.y = this.y - 45;
			b.setOwner(this);
			b.setDirect(direct);
			b.setAction("hit1");
			gc.gameScene.addChild(b);
			this.magicBulletArray.push(b);
		}
		
		private function doHi2(direct:uint) : void
		{
			var b:FollowTargetBullet = new FollowTargetBullet("Monster402Bullet1");
			b.x = this.x;
			b.y = this.y;
			b.setOwner(this);
			b.setIsDestroyWhenLastFrame(false);
			b.setDestroyInCount(48);
			b.setIsDestroyWhenOwnerHurt(false);
			b.setDirect(direct);
			b.setAction("hit2");
			gc.gameScene.addChild(b);
			this.magicBulletArray.push(b);
		}
		
		private function doHi3(direct:uint) : void
		{
			var b:SpecialEffectBullet = new SpecialEffectBullet("Monster403Bullet3");
			b.x = this.x;
			b.y = this.y;
			b.getClip().transform.colorTransform = new ColorTransform(1,0.5,0.5);
			b.setOwner(this);
			b.setDirect(direct);
			b.setAction("hit3");
			gc.gameScene.addChild(b);
			this.magicBulletArray.push(b);
		}*/
	}
}
